import matplotlib.pyplot as plt
import pylab
import cv2 as cv
import numpy as np
img_path = "./img/pinghua/danghui_jiaoyan.bmp"
img = cv.imread(img_path, cv.IMREAD_GRAYSCALE)
fil = np.array([[1, 1, 1],                        #这个是设置的滤波，也就是卷积核
                [1, 1, 1],
                [1, 1, 1]])/9

res = cv.filter2D(img, -1, fil)                      #使用opencv的卷积函数
print(fil)
cv.imshow("img", img)
cv.imshow("res", res)                                     #显示卷积后的图片
cv.waitKey(0)
cv.destroyAllWindows()